setjmp for the png error handler. It seems setting the error handling
authorLarry Ewing <lewing@helixcode.com>
Fri, 9 Jun 2000 19:41:29 +0000 (19:41 +0000)
committerLarry Ewing <lewing@src.gnome.org>
Fri, 9 Jun 2000 19:41:29 +0000 (19:41 +0000)
2000-06-09  Larry Ewing  <lewing@helixcode.com>

* gdk-pixbuf/io-png.c (gdk_pixbuf__png_image_load_increment):
setjmp for the png error handler.  It seems setting the error
handling functions does not avoid the jump, and so not calling
setjmp was causing the incremental loader to jump into lala land.
(gdk_pixbuf__png_image_begin_load): setjmp for error handling, I'm
not sure this one is actually required but the docs say it must be
set for every call to a png_* function.
Also changed the comment to reflect the fact that setting the
error handlers does _not_ avoid the longjmp.

gdk-pixbuf/ChangeLog
gdk-pixbuf/io-png.c

index 94e7ab728d37e98b76d084c3418ceaf6b74b1d87..ec1014025c32132857bf568851e2468823746d0d 100644 (file)
@@ -1,3 +1,15 @@
+2000-06-09  Larry Ewing  <lewing@helixcode.com>
+
+       * gdk-pixbuf/io-png.c (gdk_pixbuf__png_image_load_increment):
+       setjmp for the png error handler.  It seems setting the error
+       handling functions does not avoid the jump, and so not calling
+       setjmp was causing the incremental loader to jump into lala land.
+       (gdk_pixbuf__png_image_begin_load): setjmp for error handling, I'm
+       not sure this one is actually required but the docs say it must be
+       set for every call to a png_* function.
+       Also changed the comment to reflect the fact that setting the
+       error handlers does _not_ avoid the longjmp.
+
 2000-06-06  Larry Ewing  <lewing@helixcode.com>
 
        * gdk-pixbuf/gdk-pixbuf-loader.c (gdk_pixbuf_loader_frame_done):
index 4514194842da2715cc58a6a95034dafde0a46e07..afd9ffdca290eb76bf755173cafbf957b92d9491 100644 (file)
@@ -220,7 +220,8 @@ gdk_pixbuf__png_image_load (FILE *f)
                                                 free_buffer, NULL);
 }
 
-/* These avoid the setjmp()/longjmp() crap in libpng */
+/* I wish these avoided the setjmp()/longjmp() crap in libpng instead
+   just allow you to change the error reporting. */
 static void png_error_callback  (png_structp png_read_ptr,
                                  png_const_charp error_msg);
 
@@ -299,6 +300,7 @@ gdk_pixbuf__png_image_begin_load (ModulePreparedNotifyFunc prepare_func,
         
         /* Create the main PNG context struct */
 
+               
         lc->png_read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
                                                   lc, /* error/warning callback data */
                                                   png_error_callback,
@@ -309,6 +311,13 @@ gdk_pixbuf__png_image_begin_load (ModulePreparedNotifyFunc prepare_func,
                 return NULL;
         }
 
+       if (setjmp (lc->png_read_ptr->jmpbuf)) {
+               if (lc->png_info_ptr)
+                       png_destroy_read_struct(&lc->png_read_ptr, NULL, NULL);
+                g_free(lc);
+                return NULL;
+       }
+
         /* Create the auxiliary context struct */
 
         lc->png_info_ptr = png_create_info_struct(lc->png_read_ptr);
@@ -357,7 +366,11 @@ gdk_pixbuf__png_image_load_increment(gpointer context, guchar *buf, guint size)
         lc->max_row_seen_in_chunk = -1;
         
         /* Invokes our callbacks as needed */
-        png_process_data(lc->png_read_ptr, lc->png_info_ptr, buf, size);
+       if (setjmp (lc->png_read_ptr->jmpbuf)) {
+               return FALSE;
+       } else {
+               png_process_data(lc->png_read_ptr, lc->png_info_ptr, buf, size);
+       }
 
         if (lc->fatal_error_occurred)
                 return FALSE;
@@ -522,3 +535,7 @@ png_warning_callback(png_structp png_read_ptr,
         
         fprintf(stderr, "Warning loading PNG: %s\n", warning_msg);
 }
+
+
+
+